#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
AIOT智能学习桌项目 - 异常处理
"""

class SmartDeskException(Exception):
    """智能学习桌基础异常类"""
    pass

class HardwareException(SmartDeskException):
    """硬件相关异常"""
    pass

class CameraException(HardwareException):
    """摄像头异常"""
    pass

class SensorException(HardwareException):
    """传感器异常"""
    pass

class VoiceException(SmartDeskException):
    """语音处理异常"""
    pass

class PostureDetectionException(SmartDeskException):
    """坐姿检测异常"""
    pass

class ConfigException(SmartDeskException):
    """配置异常"""
    pass

class DataException(SmartDeskException):
    """数据处理异常"""
    pass

def handle_exception(func):
    """异常处理装饰器"""
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except SmartDeskException as e:
            from utils.logger import logger
            logger.error(f"智能学习桌异常: {e}")
            raise
        except Exception as e:
            from utils.logger import logger
            logger.error(f"未知异常: {e}")
            raise SmartDeskException(f"未知错误: {e}")
    return wrapper